/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * MonthlyReport.java
 *
 * Created on 05 Nov 11, 22:31:49
 */
package Com.MakeReport_Case;

import SistemPenyewaanKamar.MainController;
import SistemPenyewaanKamar.MenuMainForm;
import java.io.IOException;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Yosefina
 */
public class MonthlyReport extends javax.swing.JDialog {

    /** Creates new form MonthlyReport */
    public MonthlyReport(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        panelUtama = new javax.swing.JPanel();
        separator = new javax.swing.JSeparator();
        labelGambar = new javax.swing.JLabel();
        tanggalLabel = new javax.swing.JLabel();
        scrollPaneTabel = new javax.swing.JScrollPane();
        monthlyReportTabel = new javax.swing.JTable();
        totalKamarTitle = new javax.swing.JLabel();
        totalGedungLabel = new javax.swing.JLabel();
        kembaliMenuFormButton = new javax.swing.JButton();
        cetakButton = new javax.swing.JButton();
        buatLaporanButton = new javax.swing.JButton();
        bulanChooser = new com.toedter.calendar.JMonthChooser();
        tahunChooser = new com.toedter.calendar.JYearChooser();
        totalGedungTitle = new javax.swing.JLabel();
        totalKamarLabel = new javax.swing.JLabel();
        jSeparator2 = new javax.swing.JSeparator();
        totalTitle = new javax.swing.JLabel();
        totalGedungKamarLabel = new javax.swing.JLabel();
        headerLabel = new javax.swing.JLabel();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        panelUtama.setBackground(new java.awt.Color(255, 255, 255));

        labelGambar.setFont(new java.awt.Font("Tahoma", 0, 36));
        labelGambar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Com/MakeReport_Case/Laporan-.JPG"))); // NOI18N
        labelGambar.setText("Monthly Report");

        tanggalLabel.setText("Tanggal Transaksi");

        monthlyReportTabel.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Tanggal", "Total Pendapatan Sewa Kamar", "Total Pendapatan Sewa Gedung", "Total Pendapatan Transaksi"
            }
        ));
        scrollPaneTabel.setViewportView(monthlyReportTabel);

        totalKamarTitle.setFont(new java.awt.Font("Tahoma", 0, 14));
        totalKamarTitle.setText("Total Pemasukkan Kamar Per Bulan");

        totalGedungLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        totalGedungLabel.setText("Rp. 0,00");

        kembaliMenuFormButton.setText("KEMBALI KE MENU MAIN FORM");
        kembaliMenuFormButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                kembaliMenuFormButtonActionPerformed(evt);
            }
        });

        cetakButton.setText("CETAK LAPORAN BULANAN");
        cetakButton.setEnabled(false);
        cetakButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cetakButtonActionPerformed(evt);
            }
        });

        buatLaporanButton.setText("Buat Laporan");
        buatLaporanButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                buatLaporanButtonActionPerformed(evt);
            }
        });

        totalGedungTitle.setFont(new java.awt.Font("Tahoma", 0, 14));
        totalGedungTitle.setText("Total Pemasukkan Gedung Per Bulan");

        totalKamarLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        totalKamarLabel.setText("Rp. 0,00");

        totalTitle.setFont(new java.awt.Font("Tahoma", 0, 14));
        totalTitle.setText("Total Pemasukkan Per Bulan");

        totalGedungKamarLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        totalGedungKamarLabel.setText("Rp. 0,00");

        headerLabel.setFont(new java.awt.Font("Tahoma", 0, 14));
        headerLabel.setForeground(new java.awt.Color(255, 0, 0));
        headerLabel.setText("Tabel Laporan Pendapatan");

        javax.swing.GroupLayout panelUtamaLayout = new javax.swing.GroupLayout(panelUtama);
        panelUtama.setLayout(panelUtamaLayout);
        panelUtamaLayout.setHorizontalGroup(
            panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUtamaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(headerLabel)
                .addGap(705, 705, 705)
                .addComponent(buatLaporanButton)
                .addContainerGap())
            .addComponent(separator, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 985, Short.MAX_VALUE)
            .addComponent(labelGambar, javax.swing.GroupLayout.DEFAULT_SIZE, 985, Short.MAX_VALUE)
            .addGroup(panelUtamaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(scrollPaneTabel, javax.swing.GroupLayout.DEFAULT_SIZE, 965, Short.MAX_VALUE)
                .addContainerGap())
            .addComponent(jSeparator2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 985, Short.MAX_VALUE)
            .addGroup(panelUtamaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(totalGedungTitle, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(totalKamarTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(18, 18, 18)
                .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(totalGedungLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(totalKamarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 206, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                .addComponent(totalTitle)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(totalGedungKamarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 235, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
            .addGroup(panelUtamaLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(kembaliMenuFormButton, javax.swing.GroupLayout.PREFERRED_SIZE, 211, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 591, Short.MAX_VALUE)
                .addComponent(cetakButton)
                .addContainerGap())
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelUtamaLayout.createSequentialGroup()
                .addContainerGap(710, Short.MAX_VALUE)
                .addComponent(tanggalLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bulanChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tahunChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        panelUtamaLayout.setVerticalGroup(
            panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUtamaLayout.createSequentialGroup()
                .addComponent(labelGambar, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(separator, javax.swing.GroupLayout.PREFERRED_SIZE, 11, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(bulanChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tahunChooser, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tanggalLabel))
                .addGap(11, 11, 11)
                .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(headerLabel)
                    .addComponent(buatLaporanButton))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(scrollPaneTabel, javax.swing.GroupLayout.PREFERRED_SIZE, 258, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelUtamaLayout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(totalKamarTitle, javax.swing.GroupLayout.DEFAULT_SIZE, 17, Short.MAX_VALUE)
                            .addComponent(totalKamarLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 14, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(totalGedungTitle, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(totalGedungLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(23, 23, 23))
                    .addGroup(panelUtamaLayout.createSequentialGroup()
                        .addGap(41, 41, 41)
                        .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(totalGedungKamarLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(totalTitle))))
                .addGap(18, 18, 18)
                .addGroup(panelUtamaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(kembaliMenuFormButton)
                    .addComponent(cetakButton))
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelUtama, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(panelUtama, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        pack();
        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        java.awt.Dimension dialogSize = getSize();
        setLocation((screenSize.width-dialogSize.width)/2,(screenSize.height-dialogSize.height)/2);
    }// </editor-fold>//GEN-END:initComponents

    private void kembaliMenuFormButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_kembaliMenuFormButtonActionPerformed
        MakeReportController.back(MonthlyReport.this, cetakButton, monthlyReportTabel,
                totalKamarLabel, totalGedungLabel, totalGedungKamarLabel, bulanChooser, tahunChooser);
}//GEN-LAST:event_kembaliMenuFormButtonActionPerformed

    private void buatLaporanButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buatLaporanButtonActionPerformed
        try {
            // TODO add your handling code here:
            MakeReportController.monthlyReport(cetakButton, bulanChooser, tahunChooser, monthlyReportTabel, totalKamarLabel, totalGedungLabel, totalGedungKamarLabel);
        } catch (SQLException ex) {
            Logger.getLogger(MonthlyReport.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IOException ex) {
            Logger.getLogger(MonthlyReport.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(this, ex.getMessage());
        }
    }//GEN-LAST:event_buatLaporanButtonActionPerformed

    private void cetakButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cetakButtonActionPerformed
        // TODO add your handling code here:
        MakeReportController.cetakLaporan(monthlyReportTabel, totalKamarLabel, totalGedungLabel, totalGedungKamarLabel);
    }//GEN-LAST:event_cetakButtonActionPerformed
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buatLaporanButton;
    private com.toedter.calendar.JMonthChooser bulanChooser;
    private javax.swing.JButton cetakButton;
    private javax.swing.JLabel headerLabel;
    private javax.swing.JSeparator jSeparator2;
    private javax.swing.JButton kembaliMenuFormButton;
    private javax.swing.JLabel labelGambar;
    private javax.swing.JTable monthlyReportTabel;
    private javax.swing.JPanel panelUtama;
    private javax.swing.JScrollPane scrollPaneTabel;
    private javax.swing.JSeparator separator;
    private com.toedter.calendar.JYearChooser tahunChooser;
    private javax.swing.JLabel tanggalLabel;
    private javax.swing.JLabel totalGedungKamarLabel;
    private javax.swing.JLabel totalGedungLabel;
    private javax.swing.JLabel totalGedungTitle;
    private javax.swing.JLabel totalKamarLabel;
    private javax.swing.JLabel totalKamarTitle;
    private javax.swing.JLabel totalTitle;
    // End of variables declaration//GEN-END:variables
}
